#include "BinaryTree.h"
#include <stdlib.h>
#include <stdio.h>


//set容器:插入数据会自动排序的容器
struct Set
{
    BSTree *tree;
    int (*compare)(ElementType,ElementType);
    void (*Travel)(ElementType);
    int (*find)(ElementType,ElementType);
};
typedef struct Set set;

set* InitSet(int(*compare)(ElementType,ElementType),void(*Travel)(ElementType),int (*find)(ElementType,ElementType))
{
    set *s = (set*)malloc(sizeof(set));
    if(s == NULL)
        return NULL;

    s->tree = InitBSTree();
    s->compare = compare;
    s->Travel = Travel;
    s->find = find;

    return s;
}

void InsertSet(set *s,ElementType element)
{
<<<<<<< HEAD
    InsertTree(s->tree,element,s->compare);
=======
    InsertElement(s->tree,element,s->compare);
>>>>>>> 0979c5004e24bc00a548bec8efd3b8a77e34ab35
}

ElementType FindSet(set *s,ElementType element)
{
    GetNodeData(FindByElement(s->tree,element,s->find));
}

void RemoveSet(set *s,ElementType element)
{
<<<<<<< HEAD
    DeleteTree(s->tree,element,s->find);
=======
    RemoveByElement(s->tree,element,s->find);
>>>>>>> 0979c5004e24bc00a548bec8efd3b8a77e34ab35
}

void TravelSet(set *s)
{
    TravelMid(s->tree,s->Travel);
<<<<<<< HEAD
    TravelPrev(s->tree,s->Travel);
=======
>>>>>>> 0979c5004e24bc00a548bec8efd3b8a77e34ab35
}
//获取容器容积
int GetSetSize(set *s)
{
    return GetNodeNumber(s->tree);
}